import 'package:get/get.dart';
import 'package:kkhousekeep/models/order_list_entity.dart';

import '../../../../net/home_order_connect.dart';

class OrderProcessingListController extends GetxController{
  late HomeOrderConnect _connect;
  final bool isSelf;
  var orderList = [].obs;
  var isShowDialog = false.obs;
  var repairId = 0.obs;

  var urgentId = 0.obs;

  OrderProcessingListController(this.isSelf);

  @override
  void onInit() {
    super.onInit();

    _connect = Get.find<HomeOrderConnect>();
    _loadNetworkData();
  }

  void _loadNetworkData() async {
    await loadList();
  }

  void filterList(int repairId,int urgentId){
    this.repairId.value = repairId;
    this.urgentId.value = urgentId;
    loadList();
  }
  Future<void> loadList() async {
    OrderListEntity orderListEntity = await _connect.getOrderList(
      type: isSelf ? 'self' : 'transferred',
      state: 'processing',
      repairArea: repairId.value.toString(),
      urgency: urgentId.value.toString(),
    );
    orderList.value = orderListEntity.obj;
  }
}